<?php ob_start();
include('mysql.php');
// $opid=$_POST['opid'];
// $follow=$_POST['follow'];
$text=$_POST['text'];
$class=$_POST['class'];
$row=mysql_query("SELECT * FROM exhibition where id = (SELECT max(id) FROM exhibition) ");
$back=mysql_fetch_assoc($row);
$maxx=$back['id']+1;

date_default_timezone_set("Asia/Shanghai");
$code = $_FILES['image'];//获取小程序传来的图片
//随机字符
$randomme = rand(1000000, 9999999);

//这一段是文件处理---------------------------
//判断文件上传情况
if(is_uploaded_file($_FILES['image']['tmp_name'])) {  
    //把文件转存到你希望的目录（不要使用copy函数）  
    $uploaded_file=$_FILES['image']['tmp_name'];  
    $username = $randomme;
    //定义图片路径
    $user_path="./exh/";  
    //判断该用户文件夹是否已经有这个文件夹  
    if(!file_exists($user_path)) {  
        //mkdir($user_path); 
        echo("不存在");
        mkdir($user_path,0777,true); 
    }  
 //-------------------------------------
 
    //$move_to_file=$user_path."/".$_FILES['file']['name'];  
    $file_true_name=$_FILES['image']['name'];  
    
    //获取时间--------------------------------------------
    $nameview=date("Y-m-d");
    
    //将时间、姓名通过MD5加密获得36位密文-----------------
    $md5_name=md5($file_true_name.$nameview);
    
    //获取后缀--------------------------------------------
    $lastpont = substr($file_true_name,strrpos($file_true_name,"."));
    //----------------------------------------------------
    
    //移动文件到指定路径----------------------------------
    $move_to_file=$user_path.$md5_name.$lastpont;//strrops($file_true,".")查找“.”在字符串中最后一次出现的位置  
    //echo "$uploaded_file   $move_to_file";  
    //----------------------------------------------------
    
    //判断移动结果
    if(move_uploaded_file($uploaded_file,iconv("utf-8","gb2312",$move_to_file))) {  
       // echo $_FILES['image']['name']."--上传成功".date("Y-m-d H:i:sa"); 
    $url= "http://www.blgza.com/formal/exh"."/". $md5_name.$lastpont;
    } else {  
        echo "目录失败".date("Y-m-d H:i:sa"); 
 
    }  
} else {  
    echo "文件获取失败".date("Y-m-d H:i:sa");  
}  
echo($url);
$sql=mysql_query( "INSERT INTO exhibition (id,url,text,class) VALUES ('$maxx','$url','$text','$class')");
?>